package com.ming.dancing.springboot.Dao;

import com.ming.dancing.springboot.entity.Course;
import com.ming.dancing.springboot.entity.Dancer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;


//继承JpaRepository来完成对数据库的操作
public interface DancerDao extends JpaRepository<Dancer,Integer>,JpaSpecificationExecutor<Dancer> {
    /**
     * 自定义sql
     * **/
    @Query(value = "select * from dancer ",nativeQuery = true)
    List<Dancer> findallDancers();


    @Query(value = "UPDATE dancer SET picture =:newFileName where id=:id",nativeQuery = true)
    @Modifying(clearAutomatically = true)
    void setpicture(@Param("id") Integer id,@Param("newFileName") String newFileName);

//    //分页查询  limit #{start},#{rows}
//    @Query(value = "select id,dancername,dancerpassword,type,age,sex,picture,wage,worktime,coursecount from dancer limit :start,:rows")
//    List<Dancer> findByPage(@Param("start") Integer start,@Param("rows") Integer rows);
//
//    @Query(value = "select count(id) from dancer")
//    //查询总共课程数目
//    Integer findTotals();

}
